import Vue from 'vue'
import axios from 'axios'

// 指向后端的URL
const Url = 'http://127.0.0.1:9000/api/v1'

axios.defaults.baseURL = Url

// 请求拦截 http://www.axios-js.com/zh-cn/docs/#%E6%8B%A6%E6%88%AA%E5%99%A8
axios.interceptors.request.use(config => {
  config.headers.Authorization = `Bearer ${window.sessionStorage.getItem('token')}`
  return config
})

Vue.prototype.$http = axios

export { Url }
